package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.Engineer;
import com.shrcl.engineerprocess.domain.EngineerProjectAssignment;
import com.shrcl.engineerprocess.domain.EngineerProjectAssignmentCriteria;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import java.util.Date;
import org.hibernate.Query;

public class EngineerProjectAssignmentCriteriaImpl extends HQLBasedPagedQueryCriteria<EngineerProjectAssignment> implements EngineerProjectAssignmentCriteria {
  private Engineer engineer;
  
  public Engineer getEngineer() {
    return this.engineer;
  }
  
  public EngineerProjectAssignmentCriteria setEngineer(final Engineer engineer) {
    this.engineer = engineer;
    return this;			
    
  }
  
  private Date startDateFrom;
  
  public Date getStartDateFrom() {
    return this.startDateFrom;
  }
  
  public EngineerProjectAssignmentCriteria setStartDateFrom(final Date startDateFrom) {
    this.startDateFrom = startDateFrom;
    return this;			
    
  }
  
  private Date startDateEnd;
  
  public Date getStartDateEnd() {
    return this.startDateEnd;
  }
  
  public EngineerProjectAssignmentCriteria setStartDateEnd(final Date startDateEnd) {
    this.startDateEnd = startDateEnd;
    return this;			
    
  }
  
  private Date endDateFrom;
  
  public Date getEndDateFrom() {
    return this.endDateFrom;
  }
  
  public EngineerProjectAssignmentCriteria setEndDateFrom(final Date endDateFrom) {
    this.endDateFrom = endDateFrom;
    return this;			
    
  }
  
  private Date endDateEnd;
  
  public Date getEndDateEnd() {
    return this.endDateEnd;
  }
  
  public EngineerProjectAssignmentCriteria setEndDateEnd(final Date endDateEnd) {
    this.endDateEnd = endDateEnd;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrcl.engineerprocess.domain.impl.EngineerProjectAssignmentImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getEngineer()) ){
    	hql += " and ((this.engineer) = (:engineer))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStartDateFrom()) ){
    	hql += " and ((this.startDate) >= (:startDateFrom))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStartDateEnd()) ){
    	hql += " and ((this.startDate) <= (:startDateEnd))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getEndDateFrom()) ){
    	hql += " and ((this.endDate) >= (:endDateFrom))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getEndDateEnd()) ){
    	hql += " and ((this.endDate) <= (:endDateEnd))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getEngineer())){
    	query.setParameter("engineer",getEngineer()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStartDateFrom())){
    	query.setParameter("startDateFrom",getStartDateFrom()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStartDateEnd())){
    	query.setParameter("startDateEnd",getStartDateEnd()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getEndDateFrom())){
    	query.setParameter("endDateFrom",getEndDateFrom()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getEndDateEnd())){
    	query.setParameter("endDateEnd",getEndDateEnd()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public EngineerProjectAssignmentCriteriaImpl() {
    initOrderBys();
  }
}
